<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SetLocationWidget.ascx.cs" Inherits="SetLocationWidget" %>

<script language="javascript" type="text/javascript">
// <!--

function Location_ChangeVisiblity(showChangeFeature)
{
    Location_TrySetVisible(document.getElementById("<%= locationTextDiv.ClientID %>"), !showChangeFeature);
    Location_TrySetVisible(document.getElementById("<%= noLocationDiv.ClientID %>"), !showChangeFeature);
    
    Location_TrySetVisible(document.getElementById("<%= changeLocationDiv.ClientID %>"), showChangeFeature);
    Location_TrySetVisible(document.getElementById("<%= changeLocationButtons.ClientID %>"), !showChangeFeature);
    Location_TrySetVisible(document.getElementById("<%= saveLocationButtons.ClientID %>"), showChangeFeature);
}

function Location_TrySetVisible(element, show)
{
    if (element != null)
        element.style.display = show ? "block" : "none";
}

function Location_ChangeLocation()
{
    Location_ChangeVisiblity(true);
    var chBox = document.getElementById("<%= changeLocationTextBox.ClientID %>");
    chBox.focus();
}

function Location_CancelChange()
{
    Location_ChangeVisiblity(false);
}

// -->
</script>

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional" ChildrenAsTriggers="true">
    <ContentTemplate>
    <div id="currentLocationDiv">
        <!-- Buddha Bar Picture here -->
        <div runat="server" id="setLocationErrorRibbon" class="ErrorRibbon" visible="false">
            That location doesn't exist!  Would you like to <a runat="server" id="createLocationHref" href="CreateLocation.aspx">create it</a>?
        </div>
        <div runat="server" id="locationTextDiv" visible="false">
            You are currently at <a href="#" runat="server" id="currentLocationHref">{Somewhere}</a>.
        </div>
        <div runat="server" id="noLocationDiv" visible="false">
            You currently have no location set.
        </div>
        <div runat="server" id="changeLocationDiv" style="display:none">
            I am at <asp:TextBox runat="server" ID="changeLocationTextBox" />.
        </div>
        <div id="changeLocationButtons" runat="server">
            <a href="#" onclick="Location_ChangeLocation();return false;">Change</a> |
            <asp:LinkButton runat="server" id="clearLocationButton" OnClick="ClearLocationButton_Click">Clear</asp:LinkButton>
        </div>
        <div id="saveLocationButtons" style="display:none" runat="server">
            <asp:LinkButton runat="server" id="saveLocationButton" OnClick="SaveLocationButton_Click">Save</asp:LinkButton> |
            <a href="#" onclick="Location_CancelChange();return false;">Cancel</a>
        </div>
    </div>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="saveLocationButton" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="clearLocationButton" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>